package top.fzqblog.functioncompose

/**
 * Created by 抽离 on 2017/8/4 0004.
 */
fun <A, B, C> compose(f: (B) -> C, g: (A) -> B): (A) -> C {
    return {x -> f(g(x))}
}

fun isOdd(x: Int) =x % 2 !=0

fun length(s: String) = s.length
val oddLength = compose(::isOdd, ::length)
val strings = listOf("a", "ab", "abc")

fun main(args: Array<String>) {
    println(strings.filter(oddLength)) // Prints "[a, abc]"
}